package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.User;
import com.example.Laboratory.Service.UserService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;

@Api(value = "Login", description = "登入")
@RestController
@RequestMapping(value = "/Login")
@CrossOrigin
public class UserController {

    @Autowired
    UserService userService;

    @ApiOperation(value = "登入", notes = "登入")
    @RequestMapping(value = "/login", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object login (User u) throws IOException {
        return ResultCode.SUCCESS.result(userService.login(u));
    }
}
